package windows;

import java.util.Calendar;
import java.util.GregorianCalendar;



public class Clock  implements Runnable
{
	WindowPrincipal window;
	GregorianCalendar	calendar;
	String				scurrent;
	Thread				thread;
	int					intday;
	int					intmonth;
	int					intyear;
	int					inthour;
	int					intminute;
	int					intsecond;
	int					intamPm;
	public void iniciarreloj()
	{
		thread=new Thread(this);
		thread.start();
	}
	@SuppressWarnings("static-access")
	public void run()
	{
		String smeses[] = {
				 "Enero", "Febrero", "Marzo", "Abril",
				  "Mayo", "Junio", "Julio", "Agosto",
				  "Septiembre", "Octubre", "Noviembre", "Diciembre"};
		while(true)
		{
			scurrent="BIENVENIDO                     ";
			calendar 	= new GregorianCalendar ();
			intday			= calendar.get(Calendar.DAY_OF_MONTH);
			intmonth			= calendar.get(Calendar.MONTH);
			intyear			= calendar.get(Calendar.YEAR);
			inthour		= calendar.get(Calendar.HOUR);
			intminute		= calendar.get(Calendar.MINUTE);
			intsecond		= calendar.get(Calendar.SECOND);
			intamPm		= calendar.get(Calendar.AM_PM);

			scurrent	+= smeses[intmonth];

			if(inthour==0)
				inthour=12;

			scurrent+=" "+intday+" de "+intyear+"   "+inthour+":";

			if(intminute<10)
				scurrent+="0";

			scurrent+=intminute+":";

			if(intsecond<10)
				scurrent+="0";

			scurrent+=intsecond+" ";

			if(intamPm==0)
				scurrent+="Am";
			else
			{
				scurrent+="Pm";
			}
			window.setTitle(scurrent);
			try
			{
				thread.sleep(1000);
			}
			catch (Exception exce)
	         {
	         }

		}

	}
	public void setwindows(WindowPrincipal newWindow)
	{
		window=newWindow;
	}

}
